package com.fsm.demo.controller.activiteMq;

import jakarta.jms.JMSException;
import jakarta.jms.TextMessage;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

/**
 * activiteMq消息接收
 */
//@Component
public class HelloListener {

//    @JmsListener(destination = "${spring.activemq.queue-name}", containerFactory = "queueListener")
//    @JmsListener(destination = "aabb", containerFactory = "queueListener")
//    public void readActiveQueue(TextMessage textMessage) throws JMSException {
//        System.out.println("接受消息时间:" + System.currentTimeMillis());
//        System.out.println("queue接受到：" + textMessage.getText());
//        //关闭自动ack
//        textMessage.acknowledge();
//    }
    @JmsListener(destination = "aabb", containerFactory = "topicListener")
    public void readActiveTopic(TextMessage textMessage) throws JMSException {
        System.out.println("接受消息时间:" + System.currentTimeMillis());
        System.out.println("queue接受到：" + textMessage.getText());
        //关闭自动ack
        textMessage.acknowledge();
    }


}
